package lc.字符串;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * @description:
 * @author: qian
 * @createDate: 2021/10/16
 */
public class 剑指Offer50_第一个只出现一次的字符 {

    public char firstUniqChar(String s) {


        Map<Character, Boolean> map = new LinkedHashMap<>();
        char[] chars = s.toCharArray();

        for (char aChar : chars) {
            map.put(aChar,!map.containsKey(aChar));
        }
        for (Map.Entry<Character, Boolean> m : map.entrySet()) {

            if (m.getValue()) {
                return m.getKey();
            }
        }
        return ' ';

    }
}
